import static org.junit.Assert.assertEquals;

import org.junit.Assert;
import org.junit.Test;

public class TestMasterDVD {
	
	//public MasterDVD(Status status, String title, int quantity, double price, int number, int totalQuantity)
	
	@Test
	public void testEqualsFalse() throws Exception
	{
		MasterDVD dvd = new MasterDVD(DVD.Status.RENTAL, "Sample Rental", 1, 0, 1, 0);
		MasterDVD compare = new MasterDVD(DVD.Status.RENTAL, "Sample Sale", 1, 0, 1, 0);
		
		Assert.assertFalse(dvd.equals(compare));
	}
	
	@Test
	//constructor 1
	public void testConstructorA() {
		
		MasterDVD a = new MasterDVD(DVD.Status.RENTAL, "Sample Rental", 9, 9.00, 00001, 15);
		//check Status
		assertEquals(DVD.Status.RENTAL, a.getStatus());
		//check name
		assertEquals("Sample Rental", a.getTitle());
		//check quantity
		assertEquals(9, a.getQuantity());
		//check price
		assertEquals(9.00, a.getPrice(), 0.1);
		//check Number
		assertEquals(00001, a.getNumber());
		//check total Quantity
		assertEquals(15, a.getTotalQuantity());
	}
	@Test
	//constructor 2
	public void testConstructorB() {
		
		MasterDVD a = new MasterDVD("00003 0001 0002 R 000.00 Sample Rental            ");
		MasterDVD b = new MasterDVD("00003 0001 0002 S 000.00 Sample Rental            ");
		//check Status A
		assertEquals(DVD.Status.RENTAL.getCode(), a.getStatus().getCode());
		//check Status B
		assertEquals(DVD.Status.SALE.getCode(), b.getStatus().getCode());
		//check name
		assertEquals("Sample Rental", a.getTitle());
		//check quantity
		assertEquals(0001, a.getQuantity());
		//check price
		assertEquals(000.00, a.getPrice(), 0.1);
		//check Number
		assertEquals(00003, a.getNumber());
		//check total Quantity
		assertEquals(0002, a.getTotalQuantity());
	}
	
	@Test
	//toString()
	public void testToString() 
	{
		MasterDVD a = new MasterDVD("00002 0000 0002 R 000.00 Sample Rental            ");
		//check toString() functionality
		assertEquals("00002 0000 0002 R 000.00 Sample Rental            ", a.toString());
	}
	
	@Test
	//set Quantity 
	public void testSetQuantity() 
	{
		MasterDVD a = new MasterDVD("00002 0000 0002 R 000.00 Sample Rental            ");
		a.setQuantity(10);
		//check quantity 
		assertEquals(10, a.getQuantity());
	}
	
	@Test
	//set Number 
	public void testSetNumber() 
	{
		MasterDVD a = new MasterDVD("00002 0000 0002 R 000.00 Sample Rental            ");
		a.setNumber(10);
		//check Number
		assertEquals(10, a.getNumber());
	}
	
	@Test
	//constructor 3 status if/else
	public void testCompareTo() {
		MasterDVD a = new MasterDVD("00002 0000 0002 R 000.00 Sample Rental            ");
		MasterDVD b = new MasterDVD("00003 0000 0002 R 000.00 Sample Rental            ");
		//ensure compares true & false
		assertEquals(0, a.compareTo(a));
		Assert.assertTrue(0 != a.compareTo(b));
	}
	
}
